package org.example.service.impl;

import org.example.mapper.StoreMapper;
import org.example.model.Store;
import org.example.model.StoreExample;
import org.example.service.StoreService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StoreServiceImpl implements StoreService {

    @Autowired
    private StoreMapper storeMapper;

    @Override
    public List<Store> getStoreList() {
        return storeMapper.selectByExample(new StoreExample());
    }

    @Override
    public int create(Store store) {
        store.setId(null);
        return storeMapper.insertSelective(store);
    }

    @Override
    public int delete(Long id) {
        return storeMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int update(Long id,Store store) {
        store.setId(id);
        return storeMapper.updateByPrimaryKeySelective(store);
    }

    @Override
    public Store getStoreById(Long id) {
        return storeMapper.selectByPrimaryKey(id);
    }
}
